package lanou.autohome;

import android.content.Intent;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ListView;
import android.widget.RadioGroup;
import android.widget.Toast;

import java.util.ArrayList;

import cn.bmob.v3.BmobUser;
import lanou.autohome.basetool.BaseActivity;
import lanou.autohome.findcar.FindCarFragment;
import lanou.autohome.find.FindFragment;
import lanou.autohome.forum.ForumFragment;

import lanou.autohome.my.MeFragment;
import lanou.autohome.my.MyBemoUser;
import lanou.autohome.recommend.RecommendFragment;

/**
 * Created by dllo on 16/8/15.
 */
public class GroupActivity extends BaseActivity implements RadioGroup.OnCheckedChangeListener {

    private DrawerLayout layout;
    private FrameLayout frameLayout;
    private RadioGroup radioGroup;
    private ListView listView;
    private boolean f = false;
    private MeFragment meFragment;

    @Override
    protected int setLayout() {
        return R.layout.activity_group;
    }

    @Override
    protected void intiView() {
        radioGroup = bindView(R.id.activity_group_radiogroup);
        radioGroup.setOnCheckedChangeListener(this);
        radioGroup.check(R.id.activity_group_tuijian);
        layout = bindView(R.id.drawerLayout_group_activity);
        frameLayout = bindView(R.id.activity_group_framelayout);
        FrameLayout chouti = bindView(R.id.activity_group_framelayout_chouti);
//        listView = bindView(R.id.listview_quanbu_group_activity);
        DrawerLayout drawerLayout = bindView(R.id.drawerLayout_group_activity);
        //防止其他页打开抽屉
        drawerLayout.bringToFront();
        drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    }

    @Override
    protected void intiData() {

        meFragment = new MeFragment();
        GroupAdapter groupAdapter = new GroupAdapter(getApplicationContext());
        final ArrayList<String> strings = new ArrayList<>();
        strings.add("全部");
        strings.add("媳妇当车模");
        strings.add("美人计");
        strings.add("论坛名人堂");
        strings.add("论坛讲师");
        strings.add("精挑细选");
        strings.add("现身说法");
        strings.add("高端阵地");
        strings.add("电动车");
        strings.add("汇买车");
        strings.add("行车点评");
        strings.add("超级试驾员");
        strings.add("海外购车");
        strings.add("经典老车");
        strings.add("妹子选车");
        strings.add("优惠购车");
        strings.add("原创大片");
        strings.add("顶配风采");
        strings.add("改装有理");
        strings.add("养车有道");
        strings.add("首发阵营");
        strings.add("新车直播");
        strings.add("历史选题");
        strings.add("摩友天地");
        strings.add("蜜月之旅");
        strings.add("甜蜜婚礼");
        strings.add("摄影课堂");
        strings.add("车友聚会");
        strings.add("单车部落");
        strings.add("杂谈俱乐部");
        strings.add("华北游记");
        strings.add("西南游记");
        strings.add("东北游记");
        strings.add("西北游记");
        strings.add("华中游记");
        strings.add("华南游记");
        strings.add("华东游记");
        strings.add("港澳台游记");
        strings.add("海外游记");
        strings.add("沧海游记");
        groupAdapter.setStrings(strings);
//        listView.setAdapter(groupAdapter);
//        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//            @Override
//            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//                Toast.makeText(GroupActivity.this, strings.get(position), Toast.LENGTH_SHORT).show();
//            }
//        });
    }

    //抽屉
    public void openDrawer() {
        layout.openDrawer(Gravity.RIGHT);
        layout.setFocusable(true);
    }


    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {

        FragmentManager fm = getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        switch (checkedId) {
            case R.id.activity_group_tuijian:
                ft.replace(R.id.activity_group_framelayout, new RecommendFragment());
                break;
            case R.id.activity_group_luntan:
                ft.replace(R.id.activity_group_framelayout, new ForumFragment());
                break;
            case R.id.activity_group_findcar:
                ft.replace(R.id.activity_group_framelayout, new FindCarFragment());
                break;
            case R.id.activity_group_find:
                ft.replace(R.id.activity_group_framelayout, new FindFragment());
                break;
            case R.id.activity_group_me:

                ft.replace(R.id.activity_group_framelayout, meFragment);

                break;
        }
        ft.commit();
    }

    @Override
    public void onClick(View v) {
    }

}
